package com.onpositive.wiki3.catmodels;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;

import com.onpositive.wiki2.whole.model.ITemplateAccess;
import com.onpositive.wiki3.db.catmodel.Category;

public class FileBasedWordsProvider {

	HashMap<Integer, String[]> maps = new HashMap<Integer, String[]>();
	private ITemplateAccess ts;

	public FileBasedWordsProvider(String ps,ITemplateAccess ts) throws IOException {
		DataInputStream dd = new DataInputStream(new BufferedInputStream(
				new FileInputStream(ps)));
		this.ts=ts;
		try{
		while (true) {
			int pid = dd.readInt();
			int count = dd.readInt();
			String[] ss = new String[count];
			for (int a = 0; a < count; a++) {
				ss[a] = dd.readUTF();
			}
			maps.put(pid, ss);
		}
		}catch (EOFException e) {
		}
	}

	public String[] getWords(Category c) {		
		return maps.get(c.id());
	}
}
